package cn.mediatek.server;

import cn.hutool.core.util.StrUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@SpringBootApplication
@EnableCaching
public class WebApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(WebApplication.class, args);

		//启动成功后打印
		try {
			Environment environment = context.getBean(Environment.class);
			String ip = InetAddress.getLocalHost().getHostAddress();
			String port = environment.getProperty("server.port");
			String contextPath = StrUtil.nullToDefault(environment.getProperty("server.servlet.context-path"), "");
			System.out.println("\r\n启动成功：http://" + ip + ":" + port + contextPath);
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
	}

}
